#include <stdio.h>
int pathnum(int x,int y);
int m,n; 
int main() {

    int result;
    scanf("%d,%d", &m,&n);    
    result=pathnum(m-1,n-1);
    printf("%d",result);
    return 0;
}

int pathnum(int x,int y)
{
	int arr[30][30],i,j;
	for (i = 0; i < m; i++) 
       for (j = 0; j < n; j++) 
        scanf("%d",&arr[i][j]);  
     
	if(arr[x][y])
	   return 0;
	else  {
	if(x&&y)
	   return pathnum(x-1,y)+pathnum(x,y-1);
    if((x==0)&&(y!=0))
	   return pathnum(x,y-1);
	if((y==0)&&(x!=0))
	    return pathnum(x-1,y);   
	if(y==0&&x==0)
        return 1;  }
}



